/**
 * Copyright (C), 2015-2019, XXX有限公司
 * FileName: ActivityController
 * Author:   zhouheng
 * Date:     2019/4/17 22:48
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.portal.controller;

import com.activity.draw.bean.ActivityTurntableDrawReq;
import com.activity.draw.bean.AwardDrawRecordBean;
import com.activity.draw.common.ResultResp;
import com.activity.draw.service.ActivityTurntableDrawService;
import com.portal.support.BaseController;
import com.portal.support.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 〈一句话功能简述〉<br> 
 * 〈〉
 *
 * @author zhouheng
 * @create 2019/4/17
 * @since 1.0.0
 */
@Controller
@RequestMapping("/activity")
public class ActivityController extends BaseController {

    @Autowired
    ActivityTurntableDrawService activityTurntableDrawService;

    @GetMapping("/index")
    public String index(){
        return "activity/index";
    }

    @PostMapping("/doDraw")
    public ResponseEntity doDraw(){
        ActivityTurntableDrawReq drawReq = new ActivityTurntableDrawReq();
        drawReq.setUid(Integer.parseInt(getUid()));

        ResultResp<AwardDrawRecordBean> resp = activityTurntableDrawService.doDraw(drawReq);
        ResponseData data=new ResponseData();
        data.setCode(resp.getReturnCodeEnum().getCode());
        data.setMessage(resp.getReturnCodeEnum().getMsg());
        data.setData(resp.getResult());

        return ResponseEntity.ok(data);
    }
}